package July;

import java.util.Arrays;
import java.util.Scanner;

public class Day0725 {

    //计算日期到天数转换
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int year = scanner.nextInt();
            int month = scanner.nextInt();
            int day = scanner.nextInt();
            int res = Day(year,month,day);
            System.out.println(res);
        }
    }

    private static int Day(int year, int month, int day) {
        int [] Day = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} ;
        //判断是否是闰年
        if (year % 4 == 0 && year % 100 != 0 || year%400 == 0)
            Day[1] = 29;

        int res = 0;

        for (int i = 0; i < month-1; i++) {
            res += Day[i];
        }
        res += day;

        return res;
    }




    //幸运的袋子
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = 0;
        while (scanner.hasNextInt()){
            n = scanner.nextInt();

            int[] daiNums = new int[n];
            for (int i = 0; i < n; i++) {
                daiNums[i] = scanner.nextInt();
            }

            Arrays.sort(daiNums);

            int res = find(daiNums,0,0,1);
            System.out.println(res);
        }
    }
    //回溯解决
    private static int find(int[] daiNums, int i, long sum,int num) {
        int count = 0;

        for (int j = i; j < daiNums.length; j++) {
            sum += daiNums[i];//和
            num *= daiNums[i];//积

            if (sum > num){
                count += 1+find(daiNums,j+1,sum,num);
            } else if (daiNums[i] == 1) {
                count += find(daiNums,j+1,sum,num);
            }else
                break;

            sum -= daiNums[j];
            num /= daiNums[j];

            while (j<daiNums.length - 1 && daiNums[j] == daiNums[j+1]){
                j++;
            }
        }
        return count;
    }
}
